#include <iostream>
#include <rclcpp/rclcpp.hpp>

namespace handeye_calibration
{

  class HandEyeCalibration : public rclcpp::Node
  {
  public:
    HandEyeCalibration() = delete;
    HandEyeCalibration(const std::string &node_name, const rclcpp::NodeOptions &node_options = rclcpp::NodeOptions()) : rclcpp::Node(node_name, node_options) {}
    ~HandEyeCalibration() = default;
    void start() { std::thread{std::bind(&HandEyeCalibration::handle, this)}.detach(); }
    void handle()
    {
      RCLCPP_INFO(this->get_logger(), "starting...");
      // char in_data[8];
      // std::cin.clear();
      // std::cin.getline(in_data, 8);
      // std::string in_data_str(in_data);
      std::string in_data_str;
      std::cin >> in_data_str;
      // 移动到目标点,输入s---即可保存当前机器人关节角度,法兰的位姿和点云文件路径
      RCLCPP_INFO(this->get_logger(), "cin=%s", in_data_str.c_str());
    }
  };

} // namespace handeye_calibration

int main(int argc, char **argv)
{
  // Force flush of the stdout buffer.
  setvbuf(stdout, NULL, _IONBF, BUFSIZ);
  rclcpp::init(argc, argv);
  auto node = std::make_shared<handeye_calibration::HandEyeCalibration>("handeye_calibration_node");
  // Loop event detection
  node->start();
  rclcpp::spin(node);
  // destory node
  rclcpp::shutdown();
  return 0;
}